package com.broada.apm.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * thrift连接代理
 * @author jianfei.xu
 * @date   2016年3月25日
 *
 */
public class ThriftControllerProxy implements InvocationHandler {
	private Object realObj; //真实对象

	public ThriftControllerProxy(Object realObj) {
		super();
		this.realObj = realObj;
	}

	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		try {
			return method.invoke(realObj, args);
		} catch (Exception e) {
			LOG.error(proxy.getClass().getName() + "." + method.getName() + "调用出现异常：", e);
		}
		
		return null;
	}

	private static Logger LOG = LoggerFactory.getLogger(ThriftControllerProxy.class);
}
